# -*- coding: GBK -*-
# server set
# SERVER_ADDR = '10.240.224.54'  # server addr
SERVER_ADDR = '127.0.0.1'  # server addr
SERVER_PORT = 6666  # server port

# msg id
MSG_CS_LOGIN = 0x1001

MSG_CS_REGISTER = 0x1002

SERVER_MESSAGE = 0x3001

CLIENT_MESSAGE = 0x4001

# msg type
SERVER_FEEDBACK = 0x3100
SERVER_CLIENTID_DATA = 0x3200
SERVER_CREATE_MONSTER = 0x3300
SERVER_SYNC_MONSTER = 0x3400
SERVER_KILL_MONSTER = 0x3500
SERVER_SYNC_PLAYER = 0x3600
SERVER_PLAYER_DIE = 0x3700
SERVER_CREATE_MISSILE = 0x3800
SERVER_SYNC_MISSILE = 0x3900
SERVER_DESTORY_MISSILE = 0x3A00
SERVER_MISSILE_EXPLOSION = 0x3B00
SERVER_CREATE_OTHER_PLAYER = 0x3C00
SERVER_ALL_ENTITIES = 0x3D00
SERVER_SYNC_OTHER_PLAYER = 0x3E00
SERVER_SYNC_OTHER_PLAYER_SHOOT = 0x3F00
SERVER_CREATE_TRAP = 0x4100
SERVER_ELEPHANT_ATTACK = 0x4200
SERVER_PLAYER_DISCONNECT = 0x4300
SERVER_NEXT_LEVEL_TIME = 0x4400
SERVER_HIGHEST_SCORE = 0x4500


# server fade back
COMMAND_LOGIN_SUCCESSFUL = 0x3101
COMMAND_REGISTER_SUCCESSFUL = 0x3102

COMMAND_WRONG_PASSWORD = 0x3103
COMMAND_NAME_ALREADY_EXISTS = 0x3104
COMMAND_DATABASE_ERROR = 0x3105
COMMAND_LOGIN_ALREADY = 0x3106

# server data code
COMMAND_SEND_CLIENTID = 0x3201


# net work state
NET_STATE_STOP = 0  # state: init value
NET_STATE_CONNECTING = 1  # state: connecting
NET_STATE_ESTABLISHED = 2  # state: connected


# header set
NET_HEAD_LENGTH_SIZE = 4  # 4 bytes little endian (x86)
NET_HEAD_LENGTH_FORMAT = '<I'

NET_HEAD_SERVICE_ID_LENGTH_SIZE = 4
NET_HEAD_SERVICE_ID_FORMAT = '=hh'


# net work event style
NET_CONNECTION_NEW = 0  # new connection
NET_CONNECTION_LEAVE = 1  # lost connection
NET_CONNECTION_DATA = 2  # data coming


NET_HOST_DEFAULT_TIMEOUT = 70


# client set
MAX_HOST_CLIENTS_INDEX = 0xffff
MAX_HOST_CLIENTS_BYTES = 16


# service ID and command ID
LOGIN_SERVICE_ID = 0x0100
LOGIN_SERVICE_LOGIN_CMD = 0x0101
LOGIN_SERVICE_REGISTER_CMD = 0x0102
GAME_RESTART_CMD = 0x0103

PLAYER_ENTITY_SERVICE_ID = 0x0200
PLAYER_ENTITY_REGISTER_CMD = 0x0201
PLAYER_ENTITY_SYNC_CMD = 0x0202
PLAYER_ENTITY_ATTACK_CMD = 0x0203
PLAYER_SKILL_LEVEL_UP_CMD = 0x0204

MONSTER_ENTITY_SERVICE_ID = 0x0300
MONSTER_ENTITY_ATTACK_CMD = 0x0301
PUMPKIN_HIT_CMD = 0x0302

MISSILE_ENTITY_SERVICE_ID = 0x0400
MISSILE_ENTITY_SHOOT_CMD = 0x0401
MISSILE_ENTITY_HIT_CMD = 0x0402

TRAP_ENTITY_SERVICE_ID = 0x0500
TRAP_ENTITY_CREATE_CMD = 0x0501
MONSTER_ENTER_ICE_TRAP_CMD = 0x0502
MONSTER_OUTER_ICE_TRAP_CMD = 0x0503
NEEDLE_TRAP_HURT_MONSTER_CMD = 0x0504


# server frame time
SERVER_FRAME_TIME = 0.1

# level wait time
LEVEL_WAIT_TIME = 10

# monster generate interval
MONSTER_GEN_INTERVAL = 1

# entity type
PLAYER_ENTITY_TYPE = 1
MONSTER_ENTITY_TYPE = 2
TRAP_ENTITY_TYPE = 3
PLAYER_MISSILE_ENTITY_TYPE = 4
MONSTER_PUMPKIN_ENTITY_TYPE = 5




